package com.hpin.mlxteacher.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.widget.CircleImageView;

import java.util.List;

/**
 * Created by Aaron on 2015/7/16.
 */
public class NewsItemAdapter extends BaseAdapter {

    private Context ctx;
    private List<String> size;
    public NewsItemAdapter(Context ctx, List<String> size) {
        this.ctx = ctx;
        this.size = size;
    }

    @Override
    public int getCount() {

//        LogUtil.e("TAG", "getCount==>" + size.size());

        return size.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder=null;

//        LogUtil.e("TAG", "getView ? ======================== ?");

        if (convertView == null) {

            convertView = View.inflate(ctx, R.layout.item_news_message, null);
            viewHolder = new ViewHolder();
            viewHolder.ci_pic = (CircleImageView) convertView.findViewById(R.id.ci_pic);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
            viewHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            convertView.setTag(viewHolder);

        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }

		viewHolder.tv_title.setText("消息标题");
		viewHolder.tv_time.setText("昨天 19:08");
		viewHolder.tv_content.setText("我是消息内容");
        viewHolder.ci_pic.setImageResource(R.drawable.login_top_icon);

        return convertView;
    }

    private class ViewHolder {
        private CircleImageView ci_pic;
        private TextView tv_title;
        private TextView tv_time;
        private TextView tv_content;

    }
}
